Smith normal form